package com.example.textileexpres.widget;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.textileexpes.beans.GoodsDetailBean;
import com.itboye.textileexpres.R;
import com.itboye.textileexpres.util.BaseDialogFragment;
/**
 *商品的属性
 */
public class DertailServProduct_attr extends BaseDialogFragment {
	LinearLayout lkintower;
	Context context;
	GoodsDetailBean detailBean;
	TextView ok;

	public DertailServProduct_attr(Context context, GoodsDetailBean detailBean) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.detailBean = detailBean;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.dialog_detail_product_attr, null);
		lkintower=(LinearLayout) getActivity().findViewById(R.id.lkintower);
		ok=(TextView) getActivity().findViewById(R.id.ok);
		return view;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		System.out.println("LayoutInflater"+detailBean.getProperties().size());

		for (int i = 0; i < detailBean.getProperties().size(); i++) {

			View view=LayoutInflater.from(getActivity()).inflate(R.layout.item_product, null);
			
			TextView tvdialog_detail=(TextView) view.findViewById(R.id.tvdialog_detail);
			TextView tvdialog_detail_service=(TextView) view.findViewById(R.id.tvdialog_detail_service);
			tvdialog_detail_service.setText(detailBean.getProperties().get(i).getProp_name()+":");
			
			StringBuffer sb=new StringBuffer();
			for(int j=0;j<detailBean.getProperties().get(i).getProp_value_list().size();j++){
				sb.append(detailBean.getProperties().get(i).getProp_value_list()
					.get(j).getValue_name()+",");
			}
			tvdialog_detail.setText(sb.substring(0, sb.length()-1));
			lkintower.addView(view);
			
			
		}
		ok.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dismiss();
			}
		});
	}

}
